package cn.kgc.controller;

import cn.kgc.entity.Score;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/6/28
 * @Description:
 */
@RestController
@RequestMapping("score")
public class ScoreController {

    @Value("${server.port}")
    private String port;


    //http://192.168.1.2:8503/score/getById?id=10
    @RequestMapping("getById")
    public String getById(Integer id) {
        System.out.println("id = " + id);
        return "ScoreController ok port = "+port;
    }


    @RequestMapping("getById2/{id}")
    public String getById2(@PathVariable("id") Integer id) {
        System.out.println("id = " + id);
        return "ScoreController ok port = "+port;
    }

    @RequestMapping("add")
    public String addScore(@RequestBody Score score) {
        System.out.println("score = " + score);
        return "ScoreController ok port = "+port;
    }

    @RequestMapping("select")
    public Score selectByCourseName(String name) {
        Score score = new Score();
        score.setCourse(name);
        score.setId(10);
        score.setScore(90);
        return  score;
    }

}
